package com.ordertracker.constant;

import com.ordertracker.util.Preconditions;

/**
 * Description of class.
 * Created 1/18/13 1:57 PM
 *
 * @author andrey.rodin@playtech.com
 */

public enum DocumentType implements GetByName<DocumentType>{
    ORDER("Order"),
    INVOICE("Invoice"),
    PAYMENT_ORDER_IN("PaymentOrderIn"),
    PAYMENT_ORDER_OUT("PaymentOrderOut"),
    ORDER_INPUT_DATA("OrderInputData");

    private String name;

    private DocumentType(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }


    public DocumentType getByName(String name) {
        Preconditions.<String>checkNull(name,"DocumentType: parameter=name must be not null!");
        for (DocumentType type : DocumentType.values()) {
            if (type.getName().equals(name))
                return type;
        }

        return null;
    }
}
